<template>
	<view><web-view :src="url" style="width: 100%;"></web-view></view>
</template>

<script>
export default {
	data() {
		return {
			url: '',
			userInfo: {},
			token: ''
		};
	},
	async onLoad(options) {
		await this.getToken();
		await this.getUserInfo();
	},
	methods: {
		// 获取客服touken
		async getToken() {
			var res = await this.$get('server/index/getkefutoken');
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				return;
			}
			this.token = res.token;
		},
		// 获取个人信息
		async getUserInfo() {
			var res = await this.$get('server/login/loaduser');
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				return;
			}
			this.userInfo = res.data.user;
			var jwt = this.$store.get('jwt');
			this.url = `http://kefu.dlhuoshi.com/yk_chat?token=${this.token}&yk_uid=${this.userInfo.id}&yk_avatar=${this.userInfo.headimgurl}&yk_name=${this.userInfo.nickname}`;
			console.log('url====');
			console.log(this.url);
		}
	}
};
</script>

<style lang="scss"></style>
